<!-- public/index.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>运动打卡日历</title>
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body class="bg-gray-100 flex items-center justify-center min-h-screen font-sans">

    <!-- 密码登录界面 -->
    <div id="login-screen" class="w-full max-w-sm mx-auto">
        <div class="bg-white rounded-2xl shadow-lg p-8">
            <h2 class="text-2xl font-bold text-center text-gray-800 mb-6">访问授权</h2>
            <form id="login-form">
                <div class="mb-4">
                    <label for="password" class="block text-gray-700 text-sm font-bold mb-2">请输入访问密码:</label>
                    <input type="password" id="password-input" class="shadow appearance-none border rounded w-full py-3 px-4 text-gray-700 leading-tight focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="******">
                </div>
                <p id="error-message" class="text-red-500 text-sm mb-4 h-5"></p>
                <button type="submit" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-4 rounded-lg focus:outline-none focus:ring-4 focus:ring-indigo-300 transition-colors">
                    进入
                </button>
            </form>
        </div>
    </div>

    <!-- 主应用界面 (默认隐藏) -->
    <div id="app-container" class="w-full max-w-2xl mx-auto hidden p-4">
        <div class="bg-white rounded-2xl shadow-lg p-6 sm:p-8">
            <div class="text-center mb-4">
                <h1 class="text-3xl font-bold text-gray-800">运动打卡日历</h1>
                <p class="text-gray-500 mt-2">记录每一次坚持</p>
            </div>

            <!-- 统计数据区域 -->
            <div id="stats-container" class="grid grid-cols-2 sm:grid-cols-4 gap-4 text-center mb-6 p-4 bg-gray-50 rounded-lg">
                <div>
                    <p class="text-sm text-gray-500">本周</p>
                    <p id="stats-week" class="text-2xl font-bold text-indigo-600">0</p>
                </div>
                <div>
                    <p class="text-sm text-gray-500">本月</p>
                    <p id="stats-month" class="text-2xl font-bold text-indigo-600">0</p>
                </div>
                <div>
                    <p class="text-sm text-gray-500">本年</p>
                    <p id="stats-year" class="text-2xl font-bold text-indigo-600">0</p>
                </div>
                <div>
                    <p class="text-sm text-gray-500">总计</p>
                    <p id="stats-total" class="text-2xl font-bold text-indigo-600">0</p>
                </div>
            </div>

            <!-- 月份导航 -->
            <div class="flex justify-between items-center mb-4">
                <button id="prev-month-btn" class="p-2 rounded-full hover:bg-gray-200 transition-colors">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path></svg>
                </button>
                <h2 id="calendar-title" class="text-xl sm:text-2xl font-bold text-gray-700"></h2>
                <button id="next-month-btn" class="p-2 rounded-full hover:bg-gray-200 transition-colors">
                    <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
                </button>
            </div>

            <!-- 日历网格 -->
            <div class="grid grid-cols-7 gap-1 sm:gap-2 text-center text-sm mb-4">
                <div class="font-bold text-gray-500">日</div>
                <div class="font-bold text-gray-500">一</div>
                <div class="font-bold text-gray-500">二</div>
                <div class="font-bold text-gray-500">三</div>
                <div class="font-bold text-gray-500">四</div>
                <div class="font-bold text-gray-500">五</div>
                <div class="font-bold text-gray-500">六</div>
            </div>
            <div id="calendar-grid" class="grid grid-cols-7 gap-1 sm:gap-2"></div>

            <!-- 打卡与操作区域 -->
            <div class="mt-6 pt-6 border-t">
                <div class="mb-4">
                    <label for="remarks-input" class="block text-gray-700 text-sm font-bold mb-2">备注 (可选)</label>
                    <textarea id="remarks-input" rows="2" class="shadow appearance-none border border-gray-300 rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring-2 focus:ring-indigo-500 placeholder-gray-400 resize-y transition-all duration-200" placeholder="今天做了什么运动？"></textarea>
                </div>
                <div class="flex flex-col sm:flex-row gap-3">
                    <button id="checkin-btn" class="flex-1 bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-indigo-300">
                        💪 今日运动打卡
                    </button>
                    <button id="add-past-checkin-btn" class="flex-1 bg-gray-500 hover:bg-gray-600 text-white font-bold py-3 px-6 rounded-lg text-lg transition-transform transform hover:scale-105 focus:outline-none focus:ring-4 focus:ring-gray-300">
                        🗓️ 补打卡
                    </button>
                </div>
            </div>

            <!-- 详细打卡记录区域 -->
            <div id="details-section" class="mt-6 pt-4 border-t border-gray-200">
                <h3 id="details-title" class="text-lg font-semibold text-gray-700 mb-2">点击日期查看详情</h3>
                <ul id="details-list" class="list-none space-y-2 max-h-48 overflow-y-auto"></ul>
            </div>
        </div>
    </div>

    <!-- 补打卡/编辑模态框 (默认隐藏) -->
    <div id="form-modal" class="modal hidden">
        <div class="modal-content">
            <h2 id="modal-title" class="text-2xl font-bold mb-4">补打卡</h2>
            <form id="checkin-form">
                <input type="hidden" id="record-id-input">
                <div class="mb-4">
                    <label for="datetime-input" class="block text-gray-700 text-sm font-bold mb-2">选择日期和时间</label>
                    <input type="datetime-local" id="datetime-input" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
                </div>
                <div class="mb-4">
                    <label for="modal-remarks-input" class="block text-gray-700 text-sm font-bold mb-2">备注 (可选)</label>
                    <textarea id="modal-remarks-input" rows="2" class="shadow appearance-none border border-gray-300 rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring-2 focus:ring-indigo-500 placeholder-gray-400 resize-y transition-all duration-200" placeholder="今天做了什么运动？"></textarea>
                </div>
                <div class="flex justify-end gap-3">
                    <button type="button" id="cancel-btn" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-lg">取消</button>
                    <button type="submit" id="save-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded-lg">保存</button>
                </div>
            </form>
        </div>
    </div>

    <script src="script.js"></script>
</body>
</html>
